package cn.tianjindong.blog_manager.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.tianjindong.blog.mapper.BlogManagerMapper;
import cn.tianjindong.blog.mapper.BlogManagerVisitlogMapper;
import cn.tianjindong.blog.pojo.BlogManager;
import cn.tianjindong.blog.pojo.BlogManagerExample;
import cn.tianjindong.blog.pojo.BlogManagerExample.Criteria;
import cn.tianjindong.blog.pojo.BlogManagerVisitlog;
import cn.tianjindong.blog_manager.service.BlogManagerService;

@Service
public class BlogManagerServiceImpl implements BlogManagerService {

	@Autowired
	private BlogManagerMapper managerMapper;

	@Override
	public BlogManager getManagerByUsername(String username) {
		BlogManagerExample example = new BlogManagerExample();
		Criteria criteria = example.createCriteria();
		criteria.andUsernameEqualTo(username);
		List<BlogManager> list = managerMapper.selectByExample(example);
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}

	@Override
	public void updateManager(BlogManager manager) {
		BlogManagerExample example = new BlogManagerExample();
		Criteria criteria = example.createCriteria();
		criteria.andUsernameEqualTo(manager.getUsername());
		managerMapper.updateByExampleSelective(manager, example);
	}
}
